<template>
    <div id="login">
        <form class="form login">
            <h2>登陆</h2>
            <input v-model="username" type="username" class="form-control" placeholder="username" required autofocus>
            <input v-model="password" class="form-control" type="password" placeholder="Password" required>
            <button @click="login" type="submit">登陆</button>
        </form>
    </div>
</template>

<script>
export default {
    name:'Login',
    data (){
        return {
            username:'',
            password:''
        }
    },
    methods:{
        login: function(){
            let that = this;
            let username = this.username;
            let password = this.password;
            this.$AV.User.logIn(username, password).then(function (loginedUser) {
                that.$router.push('/fodder')
            }, function (error) {                
                console.log(JSON.stringify(error));
                alert("用户不存在");
            });
        }
    }
}
</script>

<style lang="scss">

</style>


